<?php

declare(strict_types=1);

namespace App\Controller\Mini\V2\Orders;

use App\Controller\Mini\V2\Controllers;
use App\Request\Orders\Order as OrderRequest;
use App\Services\Orders\Order as OrderServices;
use Psr\Http\Message\ResponseInterface;

class Order extends Controllers
{
    /**
     * 请求类
     * @var string
     */
    protected string $requestClass = OrderRequest::class;

    public function __construct(
        OrderServices $orderServices
    )
    {
        parent::__construct();
        $this->services = $orderServices;
    }

    /**
     * 详情
     * @return ResponseInterface
     * @throws \Throwable
     */
    public function read():ResponseInterface
    {
        $input = $this->input(['no']);
        $info = $this->services
            ->search($input)
            ->with(['goods', 'shop'])
            ->firstOrFail();

        return success(compact('info'));
    }
}
